package com.weijianhuawen.wjblog.web.controller;

import com.weijianhuawen.wjblog.common.aspect.ApiOperationLog;
import com.weijianhuawen.wjblog.common.utils.PageResponse;
import com.weijianhuawen.wjblog.common.utils.Response;
import com.weijianhuawen.wjblog.web.mode.vo.wiki.FindWikiArticlePreNextReqVo;
import com.weijianhuawen.wjblog.web.mode.vo.wiki.FindWikiCatalogListReqVo;
import com.weijianhuawen.wjblog.web.mode.vo.wiki.FindWikiCatalogListRspVo;
import com.weijianhuawen.wjblog.web.mode.vo.wiki.FindWikiPageListReqVo;
import com.weijianhuawen.wjblog.web.service.WikiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-12-05 22:14
 */

@RestController
@RequestMapping("wiki")
@Api(tags = "知识库前台接口")
public class WikiController {
    @Autowired
    private WikiService wikiService;

    // 获取知识库分页数据
    @PostMapping("/list")
    @ApiOperation(value = "获取前台知识库分页列表")
    @ApiOperationLog(description = "前台获取知识库信息分页列表数据")
    public PageResponse findWikiPageList(@RequestBody @Validated FindWikiPageListReqVo vo) {
        return wikiService.findWikiPageList(vo);
    }
    // 获取知识库目录列表
    @PostMapping("/catalog/list")
    @ApiOperation(value = "获取知识库目录列表")
    @ApiOperationLog(description = "获取知识库目录列表，通过知识库id查询")
    public Response findWikiCatalogList(@RequestBody @Validated FindWikiCatalogListReqVo vo) {
        return wikiService.findWikiCatalogList(vo);
    }

    // 获取知识库目录上下文
    @PostMapping("/article/preNext")
    @ApiOperation(value = "获取知识库上下文")
    @ApiOperationLog(description = "获取知识库某一篇文章的上文和下文")
    public Response findWikiArticlePreNext(@RequestBody @Validated FindWikiArticlePreNextReqVo vo) {
        return wikiService.findArticlePreNext(vo);
    }

}
